#include <stdio.h>

int main() {
    int n, i = 0, m;
    scanf("%d", &n);
    m = n;
    while (m)
    {
        i++;
        m = m / 6;
    }
    int a[i];
    for (int j = 0; j < i; j++)
    {
        a[j] = n % 6;
        n = n / 6;
    }
    for (int j = i - 1; j >= 0; j--)
        printf("%d", a[j]);
    return 0;
}